In computer systems, and in particular, as part of computer operating systems and software development environments, tools may be provided to allow the xe2x80x9cloadingxe2x80x9d and xe2x80x9clinkingxe2x80x9d of xe2x80x9csoftware modulesxe2x80x9d (e.g., object files) for execution, for example, as part of an application program. Such software modules may include instructions and/or data structures, each positioned at particular locations in the software module. Instructions in software modules may make references to instructions or data structures both inside and outside of the software module (for example, in another software module). xe2x80x9cLinkingxe2x80x9d involves xe2x80x9cresolvingxe2x80x9d these references, so that an instruction making a reference will include the location of the instruction or data structure to be accessed.
References are typically indicated by xe2x80x9csymbolsxe2x80x9d used to represent the desired location. The resolution process includes xe2x80x9cdefiningxe2x80x9d a symbolxe2x80x94assigning a value (e.g., a memory address) to the symbol by the software module that contains the locations to which access is to be allowedxe2x80x94and then substituting the symbol value for any references to the symbol used in other software modules.
In previous linking implementations, software modules needed to be linked in an order such that the symbol definition was established before the symbol was referenced by the software module being linked. For example, if a symbol xe2x80x9cA1B2C3xe2x80x9d were referenced in a particular software module, the symbol xe2x80x9cA1B2C3xe2x80x9d must have been defined by a previously loaded software module, so that a value for the symbol would be known by the linker. Where the symbol was not previously defined, the linker could abort the linking process, or could simply skip the resolution step for the particular symbol, leaving a xe2x80x9cdanglingxe2x80x9d reference in the software module being linkedxe2x80x94the instructions using the symbol reference would contain an undefined value for the memory location to access. Dangling references may cause abnormal execution (since they are undefined), and may cause corruption of other parts of the system.
Moreover, once a set of software modules has been completely linked, it heretofore has been extremely difficult to xe2x80x9cunlinkxe2x80x9d one or more of the set of software modules without compromising the integrity of the application using the software module or the system itself. Once software modules are linked, the linker generally discards all information about the linking process in order to conserve memory (information that is not necessary during execution), including any symbols used during linking. Thus, removing a particular software module from a linked set of software modules can result in dangling references by instructions to the (now removed) software module, resulting in the same problems discussed above.
An exemplary embodiment according to the present invention implements a method that includes the steps of locating a symbol reference to a symbol in a first software module, the first software module including at least one instruction using the symbol reference, and parsing a symbol table to locate an entry for the symbol, the entry for the symbol including a symbol value. The method also includes creating the entry for the symbol in the symbol table when the parsing does not locate the entry for the symbol in the symbol table, the entry for the symbol including a pending indication and a default value as the symbol value, and changing the at least one instruction using the symbol reference based on the default value.
The exemplary embodiment according to the present invention also implements a method that includes the steps of unloading a software module from a set of linked software modules and parsing a symbol table to locate at least one symbol table entry associated with a symbol defined by the software module, the at least one symbol table entry including a symbol value and a reference data structure of a number of locations using the symbol. The method also includes changing the symbol value to a default value, including in the at least one symbol table entry a pending indication, and changing the number of locations using the symbol based on the default value.
The exemplary embodiment according to the present invention also implements a system that includes a first computing environment including a linker and a number of symbol table entries, each of the number of symbol table entries corresponding to a symbol and including a symbol value and an indicator of whether the symbol is pending. The linker is coupled to the symbol table to use the symbol table to link a number of software modules loaded into a memory space together.